<?php
/**
 * +--------------------------------------------------------+
 * @Created by Phpstorm.
 * @Category Mobile.php
 * @Depiction
 * @Author hwy <429208948@qq.com>
 * @Date 2022/4/17  15:33
 * +--------------------------------------------------------+
 */

namespace App\Rules;


use Illuminate\Contracts\Validation\Rule;

class Mobile implements Rule
{
    /**
     * Create a new rule instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Determine if the validation rule passes.
     *
     * @param string $attribute
     * @param mixed $value
     * @return bool
     */
    public function passes($attribute, $value)
    {
        return preg_match('/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/', $value);
    }

    /**
     * Get the validation error message.
     *
     * @return string
     */
    public function message()
    {
        return '手机号码格式错误';
    }
}
